package interview.huawei.tjt.training.huaweijishitiku;

import java.util.Scanner;

// 字符串合并处理
public class HJ30 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while ( sc.hasNextLine() ) {

            String str = sc.nextLine();

            // 第一步
            String[] string = str.split(" ");
            StringBuffer stringBuffer1 = new StringBuffer();
            for ( String s : string ) {
                stringBuffer1.append(s);
            }
            String step1 = stringBuffer1.toString();

            // 第二步
            char[] array = sort(step1);

            // 第三步
            System.out.println(trans(array));

        }

    }

    // 排序函数
    public static char[] sort( String str ) {

        char[] ch = str.toCharArray();
        int i,j;
        for ( i = 2; i < ch.length; i += 2 ) {
            if ( ch[i] < ch[i - 2] ) {
                char temp = ch[i];
                for ( j = i; j > 0 && ch[j - 2] > temp; j -= 2 ) {
                    ch[j] = ch[j - 2];
                }
                ch[j] = temp;
            }
        }

        for ( i = 3; i < ch.length; i += 2 ) {
            if ( ch[i] < ch[i - 2] ) {
                char temp = ch[i];
                for ( j = i; j > 1 && ch[j - 2] > temp; j -= 2 ) {
                    ch[j] = ch[j - 2];
                }
                ch[j] = temp;
            }
        }

        return ch;
    }

    // 转换函数
    public static String trans ( char[] chars ) {

        for ( int i = 0; i < chars.length; i ++ ) {
            int num = -1;
            if(chars[i] >= 'A' && chars[i] <= 'F'){
                num = chars[i]-'A'+10;
            }else if(chars[i] >= 'a' && chars[i] <= 'f'){
                num = chars[i]-'a'+10;
            }else if(chars[i] >= '0' && chars[i] <= '9'){
                num = chars[i]-'0';
            }

            // 转换  在实际的笔试过程中可以使用Map来存储每个字符对应转换之后的字符，然后一个个匹配就行
            if ( num != -1 ) {
                // num 与 1 2 4 8 进行与运算，然后进行转换
                num = (num&1)*8 + (num&2)*2 + (num&4)/2 + (num&8)/8;
                if(num<10){
                    chars[i] = (char)(num+'0');
                }else if(num<16){
                    chars[i] = (char)(num-10+'A');
                }
            }
        }

        return new String(chars);
    }

}
